package com.sqf.soft.utils;

import lombok.Getter;
import lombok.Setter;

public class PageBean {

    private int pageSize = 10; // 每页显示条数
    private int page = 1; // 当前页码
    private int start = 0; // 起始位置
    private Condition condition = new Condition(); // 查询条件

    public PageBean() {
    }

    public PageBean(int pageSize, int page, Condition condition) {
        this.pageSize = pageSize;
        this.start = (page - 1) * pageSize;
        this.condition = condition;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        if (page != 0) {
            this.start = (page - 1) * pageSize;
        }
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
        if (pageSize != 0) {
            this.start = (page - 1) * pageSize;
        }
    }

    public int getStart() {
        return start;
    }

    public Condition getCondition() {
        return condition;
    }

    public void setCondition(Condition condition) {
        this.condition = condition;
    }
}

@Getter
@Setter
class Condition {

    private String userId;
    private String name;
    private String startDate;
    private String endDate;
}
